<?php

class vipAction extends T {


	function __init__() {
		
		/*
			加载模板引擎，设置权限控制
		*/
		
		$this->php->loadview()->loaddb()->helper("function")->session()->init();
		
		if(empty($this->session->userid)) exit("没有权限，这里以后在设置跳转,要注意后台是4个框架。目前想到的方法是现实一个超链接 点击跳出 _top");
	
	
	}
	

	function index() {
	
		$this->php->view->display("vip/index.php");
	
	}
	
	function ht_top(){ $this->php->view->display("vip/ht_top.php");}
	function ht_menu(){ $this->php->view->display("vip/ht_menu.php");}
	function ht_main(){ $this->php->view->display("vip/ht_main.php");}
	function ht_footer(){ $this->php->view->display("vip/ht_footer.php");}

	
	function qiye_add() {
	
		
		$this->db->settable("www_qiye")->init();
		$vo = $this->db->where("userid = ".$this->session->userid)->find();
		$this->view->assign("vo",$vo);
		$this->view->display("vip/qiye_add.php");
		
		
	}
	
	function qiye_add_do() {
	
		$V = $this->php->M("V");
		$V->qiye($_POST);
	
		$this->db->settable("www_qiye")->init();
		
		$_POST["etime"] = time();
		$vo = $this->db->where("userid = ".$this->session->userid)->update($_POST,0);
		
		if($vo) {
			echo "修改企业资料成功";
		}else {
			echo "不好意思，出错了";
		}
		
		
		
	}
	
	
	
	/*
	
	*/
	function job_menu() { $this->php->view->display("vip/job_menu.php");}
	
	function job_zp_add() {
	
		
		

		$M = $this->php->M("job");
		$M->job_tree();
		
		
		$this->view->display("vip/job_zp_add.php");
		
		
	}
	function job_zp_add_do() {
	
	
		$V = $this->php->M("V");
		$V->zhaopin($_POST);
		
		$this->db->settable("job_zhaopin")->init();
		
		
		$nu = $this->php->db->where("userid = ".$this->session->userid)->total();
		
		if($nu >= 10) {
			echo "目前每个企业只能发布10条招聘信息,请及时删除没用的招聘";
			exit();
		}
		
		
		
		$_POST["userid"] = $this->session->userid;
		$_POST["ctime"] = time();
		$_POST["etime"] = time();
		
		
		
		$vo = $this->php->db->insert($_POST,0);
		
		if($vo) {
		
			echo "招聘发布成功";
		
		}else {
		
			echo "不好意思，出现错误";
		
		}
		
	
	}
	
	function job_zp_list() {
	
		$this->db->settable("job_zhaopin")->init();
		
		$list = $this->php->db->where("userid = ".$this->session->userid)->select();
		
		$this->php->view->assign("list",$list);
		$this->php->view->display("vip/job_zp_list.php");
		
	
	}
	
	/*
		招聘信息修改，注意通过session判断是不是用户的信息，一定要检查
	*/
	function job_zp_edit(){
	
		$M = $this->php->M("job");
		$M->job_tree();
		
		$vo = $this->db->settable("job_zhaopin")->where("id=".$_GET["id"])->find();
		
		if($vo["userid"] != $this->session->userid) exit("edit error");
		
		$this->php->view->assign("vo",$vo);
	
		$this->php->view->display("vip/job_zp_edit.php"); 
	
	}
	
	function job_zp_update() {
		
		//--------------------
		$id = (int)$_POST["id"];
		unset($_POST["id"]);
		
		$v = $this->php->M("V");
		$v->zhaopin($_POST);
		//--------------------
		
		$vo = $this->db->settable("job_zhaopin")->where("id=".$id)->find();
		if($vo["userid"] != $this->session->userid) exit("update error");
		//--------------------
		
		
		$_POST["etime"] = time();
		
		$mo = $this->php->db->where("id=".$id)->update($_POST,0);
		
		if($mo){
			echo "更新招聘成功";
		}else{
			echo "更新招聘失败";
		}
	
	}
	
	function job_zp_del() {
		$id = $_GET["id"];
		
		$vo = $this->db->settable("job_zhaopin")->where("id =".$id)->find();
		if($vo["userid"] != $this->session->userid) exit("del error");
		
		
		if($this->php->db->where("id = ".$id)->delete() ) {
		
			echo "删除招聘条目成功";
		
		}else {
			echo "del error";
		}
		
		
	}
	
	
	
	/*
	
	
	
	
	
	
	*/
	
	function __destruct () {
	
		
		$debug = C("misc.debug");
		if(empty($debug)) exit();
		
		
		if(!empty($this->php->db)) {
			$str = $this->php->db->getMsg();
			echo "<hr />";
			echo $str;
		}
		
	
	
	}





}